<?php
/*------------------------------------------------------------------------------
this file is part of Web Application Kit http://webappkit.net
Copyright (C) 2006 J.Ducastel <jducastel@jducastel.fr>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
------------------------------------------------------------------------------*/

/**
* abstract template interface
* multi-engines
* @author J.Ducastel <jducastel@jducastel.fr>
* @version 
*/
class wakTemplate extends databean {
/*------------------------------------------------------------------------------
                                                                     constructor
------------------------------------------------------------------------------*/
	/**
	*
	* @access
	* /
	function () {
		$this->__construct();
	}/**/
	
	/**
	* "real" constructor
	* @access
	* /
	function __construct() {
		
	}/**/
/*------------------------------------------------------------------------------
                                                                  public methods
------------------------------------------------------------------------------*/
	/**
	* renders template with appropriate engine
	* @param
	* @access public
	* @return string
	*/
	function render() {
		// getting engine
		if (!$engine=wak::getService('wakTemplateEngine',$this->engine)) {
			return false;
		}
		return $engine->renderTemplate($this->tpl,$this->data);
	}/**/
	
	/**
	* sets template's content
	* @param string $content
	* @access public
	* @return bool
	*/
	function setContent($content) {
		// getting engine
		if (!$engine=wak::getService('wakTemplateEngine',$this->engine)) {
			return false;
		}
		if (!$this->tpl=&$engine->buildTemplate($content)) {
			return false;
		}
		return true;
		//return $this->set('content',$content);
	}/**/
	
	/**
	* sets template's source data for processing
	* @param mixed &$data
	* @access public
	* @return 
	*/
	function setData(& $data) {
		$this->data=&$data;
		return true;
	}/**/
	
	/**
	* 
	* @param
	* @access public
	* @return 
	*/
	function setId($id) {
		return $this->set('id',$id);
	}/**/
	
	/**
	* 
	* @param
	* @access public
	* @return 
	*/
	function setEngine($engine) {
		return $this->set('engine',$engine);
	}/**/
	
	/**
	* 
	* @param
	* @access public
	* @return 
	* /
	function () {
		
	}/**/
/*------------------------------------------------------------------------------
                                                                      properties
------------------------------------------------------------------------------*/
	/**
	* @var string rendering engine
	*/
	var $engine='django';
	/**
	* @var string template content
	*/
	//var $content='';
	/*
	* @var object template instance
	*/
	var $tpl;
	/**
	* @var array data source
	*/
	var $data=array();
	/**
	* @var string "unique" id
	*/
	var $id;
/*------------------------------------------------------------------------------
                                                               protected methods
------------------------------------------------------------------------------*/
	/**
	* 
	* @param
	* @access protected
	* @return 
	* /
	function () {
		
	}/**/
	
	/**
	* 
	* @param
	* @access protected
	* @return 
	* /
	function () {
		
	}/**/
	
/*------------------------------------------------------------------------------
                                                                 private methods
------------------------------------------------------------------------------*/
	/**
	* 
	* @param
	* @access private
	* @return 
	* /
	function () {
		
	}/**/
	
	/**
	* 
	* @param
	* @access private
	* @return 
	* /
	function () {
		
	}/**/
}
?>
